package com.gopay.bis.dao.payconfig.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.bis.dao.payconfig.BisBizProdPayChConfigDAO;
import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.constants.trans.PayChannel;
import com.gopay.common.domain.bis.BisBizProdPayChConfig;

/**
 * 
 * @author liujy
 *
 */
@Repository("bisBizProdPayChConfigDAO")
public class BisBizProdPayChConfigDAOImpl extends BaseDAOImpl<BisBizProdPayChConfig, String>
	implements BisBizProdPayChConfigDAO{

	@Override
	public List<BisBizProdPayChConfig> findConfigsByBankBizProds(
			List<String> prods) {
		if(null == prods || prods.isEmpty()){
			return null;
		}
		String hql = "from BisBizProdPayChConfig where bankBizProdCode in (:prods)";
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("prods", prods);
		return findByHql(hql, param);
	}
	
	@Override
	public BisBizProdPayChConfig findConfigByPayChannel(PayChannel payChannel){
		if(null == payChannel){
			return null;
		}
		String hql = "from BisBizProdPayChConfig where bankBizProdCode=:payChannel";
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("payChannel", payChannel.value);
		List<BisBizProdPayChConfig> configs = findByHql(hql, param);
		if(null == configs || configs.isEmpty()){
			return null;
		}
		return configs.get(0);
	}

}
